<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<? session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>BINDER - PROFILE</title>
		<link rel="stylesheet" type="text/css" href="style2.css" title="style2" />
		<script type="text/javascript" src="script.js"></script>
		<script type="text/javascript" src="profile.js"></script>
		<script type="text/javascript" src="cal.js"></script>
	</head>
	<body>
		<div id="wrapper">
			<div id="header"><? include('header.php'); ?></div>
			<div id="main">
				<div id="konten">
					<div class="atas-profile">
					</div>
					<div class="tengah">
						<div class="judul">
							Profil
						</div>
						<div class="isi">
						<div class = "detail-profile">
							<?php
								require("dbfunc.php");
								$uid = $_GET['uid'];
								/*if (isset($_SESSION['username'])){
									$qres1 = mysql_query("SELECT * FROM user WHERE username='{$_SESSION['username']}' ");
									$qres2 = mysql_query("SELECT * FROM achievement WHERE user='{$_SESSION['username']}' ");
								}
								else {*/
									$qres1 = mysql_query("SELECT * FROM user WHERE username='{$_GET['uid']}' ");
									$qres2 = mysql_query("SELECT * FROM achievement WHERE user='{$_GET['uid']}' ");
								//}
								while($row = mysql_fetch_array($qres1))
								{
									echo "<div class='avatar-gambar'><img class='dynamic-img' src='ava/".$row['username'].".jpg' alt='".$row['username']."' /></a></div>";
									echo "<div class='komenjudul'> ".$row['nama_lengkap']."</div>";
									echo "Jenis Kelamin: ";
									if($row['gender']==1){
										echo "Lelaki sejati";
									}else{
										echo "Wanita tulen";
									}
									echo "<br/>";
									echo "email: ".$row['email']."<br/>";
									echo "Jumlah Komentar: ".$row['jmlKom']."<br/>";
									echo "Jumlah Konten: ".$row['jmlPost']."<br/>";
									echo "About Me: ".$row['about']."<br/>";
									echo "Achievements:<br/>";
									
									while($row2 = mysql_fetch_array($qres2)){
										echo "<img  src='images/Achievements/".$row2['jenis'].".png' alt='".$row2['jenis']."' title='";
										if(isset($row2['jenis'])) {
											if($row2['jenis']==1) echo "Melakukan posting sekali";
											if($row2['jenis']==2) echo "Telah melakukan posting 10 kali";
											if($row2['jenis']==3) echo "Berkomentar sekali";
											if($row2['jenis']==4) echo "Telah berkomentar 20 kali";
											if($row2['jenis']==5) echo "Mendapat Like sebanyak 100";
											if($row2['jenis']==6) echo "Mendapat Dislike sebanyak 100";
											if($row2['jenis']==7) echo "10 hari menjadi anggota";
											if($row2['jenis']==8) echo "50 hari menjadi anggota";
											if($row2['jenis']==9) echo "Newbie";
											echo "'/>&nbsp";
										}
									}
									if (mysql_num_rows($qres2)<1) echo "Belum mendapat satu pun achievement";
								if(isset($_SESSION['username'])){
									if (strcmp($_SESSION['username'],$_GET['uid'])==0)
									echo"
									<div class='komenjudul'>Edit Profile</div>
									<div class='edit-profile'>	'
											<form action='prochange.php?username=".$_SESSION['username']."' method='post' enctype='multipart/form-data'>
												<div class='register-label'>Email <span class='btg-mrh'>*</span></div><div class='register-td'>:</div><div class='register-input'><input class='register-input-input' type='text' name='email' id='form-email' onblur='valLive(2,this,'error-email')' value='".$row['email']."' onkeyup='validateEmail()' /></div>
												<div class='clear btg-mrh' id='error-email'></div>
												<div class='register-label'>Avatar <span class='btg-mrh'>*</span></div><div class='register-td'>:</div><div class='register-input'><input class='register-input-input' type='file' name='avatar' id='form-avatar' onchange='validateAva()' /></div>
												<div class='clear btg-mrh' id='error-avatar'></div>
												<div class='register-label'>About me</div><div class='register-td'>:</div><div class='register-input'><textarea class='register-input-input' name='about' id='form-about' rows='5' cols='50' >".$row['about']."</textarea></div>
												<div class='clear btg-mrh'></div>
												<div class='register-submit'><input type='submit' name='register' value='change' id='form-button' /></div>
											</form>

									</div>
									";
								}
								}
							?>
						</div>
					</div>
					<div class="bawah-register">
					</div>
					
					<div class="daftar-konten">
							
							<div id="konten">
								
								<?php
									require("dbfunc.php");
									require("datefunc.php");
									
									$order='DESC';
									$by="tgl";
									$tags='-';
									$qres = mysql_query("SELECT * FROM konten WHERE userpost='$uid' ORDER BY $by $order");
									echo "<div id='konten-isi'>";
									if (mysql_num_rows($qres)!=0){
										echo "<div class='tengah'>";
										echo "<div class='atas'></div><div id='search-judul'>Konten yang di-post oleh ".$uid."</div>";
										
										while($row = mysql_fetch_array($qres))
										{
												echo "<div class='line-konten'></div>";
												echo "<div class='judul'>";
													echo "<a href='konten.php?jd=".$row['judul']."'>".$row['judul']."</a>";
												echo "</div>";
												echo "<div class='isi'>";
													//isi if 1 then link, 2 then gambar, 3 then video
													$tipe=$row['tipe'];
													switch ($tipe){
														case 1:	//link
															echo "<div class='isi-link'><a href='".$row['url']."'>Lihat link terkait</a></div>";
															echo "<br />Penjelasan :";
															echo "<div class='isi-about'>".$row['about']."</div>";
															break;
														case 2:	//gambar
															echo "<div class='isi-gambar'><a href='konten.php?jd=".$row['judul']."'><img src='konten/".$row['judul'].".jpg' alt='".$row['judul']."' /></a></div>";
															break;
														case 3:	//video
															echo "<iframe allowfullscreen='' width='461' height='346' frameborder='0' src='".$row['url']."'></iframe>";
															break;
														default:
															break;
													}
												echo "</div>";
												echo "<div class='detail'>";
													echo "<div class='byon'>";
														echo "Dipost oleh <strong><span class='by'><a href='profile.php?uid=".$row['userpost']."'>".$row['userpost']."</a></span></strong> pada <strong>".diffDate($row['tgl'],date('d-m-Y H:i:s'))."</strong>";
													echo "</div>";
													echo "<div class='commenter'>";
														echo "<strong><span>".$row['jmlKom']."</span></strong> komentar";
													echo "</div>";
													echo "<div class='likedislike'>";
														echo "<ul class='ldbuttons'>";
															if (isset($_SESSION['username'])){
															if(strcmp($_SESSION['username'],$row['userpost'])!=0){
										$result=mysql_query("SELECT * FROM menyukai WHERE idKonten = '".$row['id']."' AND user = '".$_SESSION['username']."'");
								if (mysql_num_rows($result)>0){
									//sudah like/dislike
									$baris = mysql_fetch_array($result);
									if ($baris['jenis']==1){	//like
										echo "<li class='islike' id='blike".$row['id']."'><a href=\"javascript:like(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
										echo "<li class='notdislike' id='bdislike".$row['id']."'></li>";
									}else{
										//dislike
										echo "<li class='notlike' id='blike".$row['id']."'></li>";
										echo "<li class='isdislike' id='bdislike".$row['id']."'><a href=\"javascript:dislike(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
									}
								}else{
									//bisa like/dislike
									echo "<li class='like' id='blike".$row['id']."'><a href=\"javascript:like(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
									echo "<li class='dislike' id='bdislike".$row['id']."'><a href=\"javascript:dislike(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
								}
															}else{
																$result=mysql_query("SELECT * FROM menyukai WHERE idKonten = '".$row['id']."' AND user = '".$row['userpost']."'");
																if (mysql_num_rows($result)>0){
																	//sudah like/dislike
																	$baris = mysql_fetch_array($result);
																	if ($baris['jenis']==1){	//like
																		echo "<li class='islike' id='blike".$row['id']."'><a href=\"javascript:like(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
																		echo "<li class='notdislike' id='bdislike".$row['id']."'></li>";
																	}else{
																		//dislike
																		echo "<li class='notlike' id='blike".$row['id']."'></li>";
																		echo "<li class='isdislike' id='bdislike".$row['id']."'><a href=\"javascript:dislike(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
																	}
																}else{
																	//bisa like/dislike
																	echo "<li class='like' id='blike".$row['id']."'><a href=\"javascript:like(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
																	echo "<li class='dislike' id='bdislike".$row['id']."'><a href=\"javascript:dislike(".$row['id'].",'".$_SESSION['username']."')\"></a></li>";
																}
															}
															}else{
																//tidak bisa apa-apa
																echo "<li class='like' id='blike".$row['id']."'><a href=\"javascript:alert('Login dahulu untuk melakukan ini ^^v')\"></a></li>";
																echo "<li class='dislike' id='bdislike".$row['id']."'><a href=\"javascript:alert('Login dahulu untuk melakukan ini ^^v')\"></a></li>";
															}
														echo "</ul>";
													echo "</div>";
													echo "<div class='count'>";
														echo "<strong><span id='jmllike".$row['id']."'>".$row['jmlLike']."</span></strong> user menyukai";
													echo "</div>";
													echo "<div class='count'>";
														echo "Tagged : <strong><span>".$row['tag']."</span></strong>";
													echo "</div>";
													echo "<div class='dkonten-clear'>";
													echo "</div>";
												echo "</div>";
																			
											
										}
									}else{
										echo "<div class='atas'></div>";
										echo "<div class='tengah'>";
											echo "<div class='judul'>";
												echo "No content yet";
											echo "</div>";
											echo "<div class='line-konten'></div>";
										
									}
									echo "<div class='bawah'></div>";
									echo "</div>";

									
									echo "</div>";
								echo "</div>";
									
								?>
								</div>
						</div>
				</div>
				<div id="sidebar"><? include('sidebar.php'); ?></div>
				</div>
			</div>
			<div id="footer">
				<div id="little">
				</div>
				<div id="siteinfo">
					&copy; 2012. YaGituDeh.<br />
					Hak cipta dilindung oleh Unang.
				</div>
				<div id="botlink">
				<ul>
					<li><a href="index.php">HOME</a></li>
					<li><a href="dkonten.php">DAFTAR KONTEN</a></li>
					<li><a href="register.php">REGISTER</a></li>
				</ul>
				</div>
			</div>
		</div>
	</body>
</html>
